#pragma once
#include "vector2D.h"
#include "Shapes.h"
#include "controls.h"
#include "gamecode.h"
#include "gametimer.h"
#include "mydrawengine.h"
#define DRAWENGINE   MyDrawEngine::GetInstance()

const Vector2D screen (SCREENWIDTH,SCREENHEIGHT);

enum currentState {STARTUP,INGAME,WRAPUP};

struct GameResult
{
	int score;
	int fuelChange;
	int moneyChange;

};

class Clock
{	
	GameTimer g_theTimer;
	int frameTimeTicker;

public:
	Clock();

	bool ticker(); //returns true after each second has passed
	bool ticker(double time); //returns true after set time has passed
};

class Game
{
private:
	bool gameIsActive;

protected:
	
	Clock theClock;

	MousePointer gTheMouse;
	


	GameResult theResult;

public:
	virtual void GameInit() = 0;
	virtual void GameMain() = 0;
	virtual void GameShutdown() = 0;
	virtual GameResult GetResult();

	bool getGameActive();
	void setGameActive(bool newCondition);
};

class RectangularGameObject
{
protected:

	Rectangle2D theShape;

	Vector2D m_position;
	Vector2D m_velocity;
	float width;
	float height;

public:	
	void init(Vector2D thePosition, float theWidth, float theHeight);
	virtual void Draw();
	virtual void Draw(int colour);
	virtual void Update(Vector2D theVelocity);
	bool CollidesWith(RectangularGameObject& other);
	//virtual void HandleCollision();
	
	void setPosition(Vector2D newPosition);
	Vector2D getPosition();
	Vector2D getVelocity();
	float getHeight();
	float getWidth();
};

class CircularGameObject
{
protected:

	Vector2D m_position;
	Vector2D m_velocity;
	float radius;

public:
	void init(Vector2D thePosition, float theRadius);
	virtual void Draw();
	virtual void Draw(int colour);
	virtual void Update(Vector2D theVelocity);
	bool CollidesWith(CircularGameObject& other);
	bool CollidesWith(RectangularGameObject& other);
	//virtual void HandleCollision();

	void setPosition(Vector2D newPosition);
	Vector2D getPosition();
	Vector2D getVelocity();
	float getRadius();

};

class Image
{
protected:
	Vector2D m_position;
	Vector2D m_velocity;
	Vector2D m_size;

	RectangularGameObject collisionBox;
	PictureIndex theImage;

	bool hasImage;

public:
	void init(Vector2D thePosition, Vector2D theSize, char* _filename);
	virtual void Draw();
	virtual void Update(Vector2D theVelocity);
	bool CollidesWith(Image& other);
	bool CollidesWith(CircularGameObject& other);
	bool CollidesWith(RectangularGameObject& other);

	void setPosition(Vector2D newPosition);
	Vector2D getPosition();
	Vector2D getVelocity();
	Vector2D getSize();
};



void TextWriter(Vector2D textPosition, const char DisplayText[], int colour = MyDrawEngine::WHITE);

void IntWriter(Vector2D numberPosition, const int DisplayInt, int colour = MyDrawEngine::WHITE);

void NumberWriter(Vector2D numberPosition, const double DisplayNum, int colour = MyDrawEngine::WHITE);